<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
use Hyperf\Crontab\Crontab;
use MoChat\App\WorkMessage\Task\MessageSyncDataTask;

$messageSyncInterval = env('MESSAGE_SYNC_INTERVAL', 15);
$messageSyncRule = "*/{$messageSyncInterval} * * * * *";

return [
    // 是否开启定时任务
    'enable' => true,
    // 通过配置文件定义的定时任务
    'crontab' => [
        (new Crontab())->setName('MessageSyncDataTask')->setRule($messageSyncRule)->setCallback([MessageSyncDataTask::class, 'execute'])->setMemo('消息同步定时任务')->setSingleton(true),
        // 销售任务同步
        (new Crontab())->setType('command')->setName('SalesTaskCommand')->setRule('*/60 * * * *')->setCallback([
            'command' => 'salesTask',
        ]),
        // 遗漏任务同步
        (new Crontab())->setType('command')->setName('CallOmissionCommand')->setRule('* 0 * * *')->setCallback([
            'command' => 'callOmission',
        ]),
        // 客服分配
        (new Crontab())->setType('command')->setName('ClientBindingCommand')->setRule('*/1 * * * *')->setCallback([
            'command' => 'clientBinding',
        ]),
        // 呼叫记录映射
        (new Crontab())->setType('command')->setName('CallRecordRelationCommand')->setRule('*/1 * * * *')->setCallback([
            'command' => 'callRecordRelation',
        ]),
        // 呼叫记录映射客户
        (new Crontab())->setType('command')->setName('CallRecordClientCommand')->setRule('*/1 * * * *')->setCallback([
            'command' => 'callRecordClient',
        ]),
        // 处理通话记录
        (new Crontab())->setType('command')->setName('CallRecordCommand')->setRule('*/1 * * * *')->setCallback([
            'command' => 'callRecord',
        ]),

        // 客户管理关联b2b内码
        (new Crontab())->setType('command')->setName('B2bClientCommand')->setRule('*/1 * * * *')->setCallback([
            'command' => 'b2bClient',
        ]),
    ],
];
